import { ref, reactive } from 'vue'
import { TASK_TYPE, TASK_STATUS, TASK_INSPECTS } from '@/utils/dictionary'
// import { getDeptList } from '@/api/org-manage/depart-manage/index'
import { getAirList, getWayList } from '@/api/task/index'

// 部门列表
const deptList = ref([])

// 巡检机场
const ariList = ref([])

// 巡检路线
const inspectionList = ref([])

export const search = reactive({
  search: [
    {
      label: '任务名称',
      type: 'input',
      key: 'name',
      props: {
        placeholder: '请输入任务名称'
      }
    },
    {
      label: '任务时间',
      type: 'date',
      key: 'occurrenceTime',
      props: {
        type: 'datetimerange',
        format: 'yyyy-MM-dd HH:mm:ss'
      }
    }
  ]
})

// 获取部门列表
// export const getDeptInfo = async function(id) {
//   const { data } = await getDeptList(id)
//   deptList.value = data?.map(it => ({
//     ...it,
//     label: it.name,
//     value: it.id
//   }))
// }

// 巡检机场 列表
export const getAirInfo = async function() {
  const { data } = await getAirList()
  ariList.value = data?.records.map(it => ({
    ...it,
    label: it.name,
    value: it.id
  }))
}

// 巡检路线 列表
export const getWayInfo = async function(id) {
  const { data } = await getWayList(id)
  inspectionList.value = data?.records.map(it => ({
    ...it,
    label: it.name,
    value: it.id
  }))
}

